using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using MobileClient.UIProcessService;

namespace MobileClient
{
	/// <summary>
	/// Summary description for ctlListEntry.
	/// </summary>
	public class ctlListEntry : Control
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.TextBox txtEntry;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.ListBox lstEntries;

		private FormResource m_objEntry;

		public ctlListEntry()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			m_objEntry = null;
		}

		public FormResource Entry
		{
			get { return m_objEntry; }
			set { m_objEntry = value; }
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if( components != null )
					components.Dispose();
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.txtEntry = new System.Windows.Forms.TextBox();
			this.btnAdd = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.lstEntries = new System.Windows.Forms.ListBox();
			// 
			// txtEntry
			// 
			this.txtEntry.Location = new System.Drawing.Point(12, 8);
			this.txtEntry.Size = new System.Drawing.Size(212, 20);
			this.txtEntry.Text = "";
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(41, 36);
			this.btnAdd.Size = new System.Drawing.Size(70, 20);
			this.btnAdd.Text = "Add";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Location = new System.Drawing.Point(125, 36);
			this.btnDelete.Size = new System.Drawing.Size(70, 20);
			this.btnDelete.Text = "Delete";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// lstEntries
			// 
			this.lstEntries.Location = new System.Drawing.Point(12, 64);
			this.lstEntries.Size = new System.Drawing.Size(212, 82);
			// 
			// ctlListEntry
			// 
			this.Controls.Add(this.lstEntries);
			this.Controls.Add(this.btnDelete);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.txtEntry);
			this.Size = new System.Drawing.Size(236, 152);

		}
		#endregion

		public void LoadSettings()
		{
			if(m_objEntry != null)
			{
			}
		}

		public void SaveSettings()
		{
			if(m_objEntry != null)
			{
			}
		}

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			lstEntries.Items.Add(txtEntry.Text);
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			int nIndex = lstEntries.SelectedIndex;
			if(nIndex >= 0)
			{
				lstEntries.Items.RemoveAt(nIndex);
			}
		}
	}
}
